#include <stdio.h>
#include <io.h>

bool EnumFileAndDir(const string &strDir,vector<string> &Dirs,vector<string> &Files)
{
	long hFile;
	_finddata_t fileinfo;
	string strSpec = strDir + "\\*.*";
	hFile = _findfirst(strSpec.c_str(),&fileinfo);
	if(hFile == -1)
	{
		return false;
	}
	Dirs.clear();
	Files.clear();
	do 
	{
		if( fileinfo.attrib & _A_SUBDIR )
		{
			if(! (strcmp(fileinfo.name,".")==0 || strcmp(fileinfo.name,"..")==0) )
			{
				Dirs.push_back(strDir+"\\"+fileinfo.name);
			}
		}
		else
		{
			Files.push_back(strDir+"\\"+fileinfo.name);
		}
		
	} while(_findnext(hFile,&fileinfo) == 0);
    return true;
}


void main()
{
	vector<string> Dirs,Files;
	EnumFileAndDir("D:\\MSRA Work Place\\Naive Bayes Classifier\\Naive Bayes classifier\\data\\20_newsgroups",Dirs,Files);
	cout<<Dirs.size()<<"dirs:"<<endl;
	copy(Dirs.begin(),Dirs.end(),ostream_iterator<string>(cout,"\n"));
	
	cout<<Files.size()<<"files:"<<endl;
	copy(Files.begin(),Files.end(),ostream_iterator<string>(cout,"\n"));
}
